package cate.game.play.skill.active;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.proce.move.AppendMove;
import cate.game.play.proce.move.AppendMoveHandler;
import cate.game.play.proce.turn.TurnCtx;

/**
 * 对敌方单位造成520%物理伤害，50%给自身附加【虚弱】，若击杀目标，则以50%攻击力追击一次，最多触发1次/n第2回合释放，冷却4回合
 */
public class 利刃幽镰裂AH extends ActiveHandler implements AppendMoveHandler {

	private double 血量调整;

	//血量调整=-5000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量调整 = args.getWDouble("血量调整", 0d);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		血量调整 += args.getWDouble("血量调整", 0d);
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (lastRound >= action.getRound().index) {
			return;
		}
		if (action.getStat().getTotalKill(skill.owner.getPid()) <= 0) {
			return;
		}
		AppendMove appendMove = new AppendMove(skill.owner, skill, this);
		appendMove.hpChangeRate = 血量调整;
		action.getTurn().addAppend(appendMove);
	}

	private int lastRound;

	@Override
	public boolean inValid(TurnCtx turn, AppendMove appendMove) {
		return lastRound >= turn.getRound().index;
	}

	@Override
	public void beforeAppendMove(TurnCtx turn, AppendMove appendMove) {

	}

	@Override
	public void afterAppendMove(TurnCtx turn, AppendMove appendMove) {
		lastRound = turn.getRound().index;
	}

	@Override
	public void onAppendMoveFail(TurnCtx turn, AppendMove appendMove) {

	}
}
